<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
</head>
<body>
<h2>图书查询</h2>
<!--按照ISBN号进行查找-->
<form action="" method="post">
ISBN:<input type="text" name="isbn">&nbsp;&nbsp;&nbsp;
<input type="submit" name="isbnsearch" value="按照ISBN进行查询">
</form><br/><br/>
<form action="" method="post">
书名:<input type="text" name="name">&nbsp;&nbsp;&nbsp;
<input type="submit" name="namesearch" value="按照书名进行模糊查询">
</form><br/><br/>
<form action="" method="post">
书名:<input type="text" name="editor">&nbsp;&nbsp;&nbsp;
<input type="submit" name="editorsearch" value="按照作者进行模糊查询">
</form><br/><br/>
<form action="" method="post">
出版社:<input type="text" name="press">&nbsp;&nbsp;&nbsp;
<input type="submit" name="presssearch" value="按照出版社进行模糊查询"><br/><br/>
</form>
<table border="1" width="1050">
<tr>
<td>ISBN</td>
<td>书名</td>
<td>定价</td>
<td>主编</td>
<td>字数</td>
<td>状态</td>
<td>印刷厂</td>
<td>出版社</td>
<td>查看详情</td>
<td>修改信息</td>
<td>删除书籍</td>
</tr>
<!--接下来开始加载数据库中的内容-->
<?php
$selectsql="select ISBN,name,price,editor,wordnum,state,print,press from books ";
//首先判断是否是ISBN查询
if(isset($_POST["isbnsearch"])&&$_POST["isbnsearch"]=="按照ISBN进行查询"){
	$isbn=$_POST["isbn"];
	$selectsql.="where ISBN='$isbn'";
}
//判断是否是书名查询
if(isset($_POST["namesearch"])&&$_POST["namesearch"]=="按照书名进行模糊查询"){
	$name=$_POST["name"];
	$selectsql.="where name like '%{$name}%'";
}
//判断是否是作者查询
if(isset($_POST["editorsearch"])&&$_POST["editorsearch"]=="按照作者进行模糊查询"){
	$editor=$_POST["editor"];
	$selectsql.="where editor like '%{$editor}%'";
}
if(isset($_POST["presssearch"])&&$_POST["presssearch"]=="按照出版社进行模糊查询"){
	$press=$_POST["press"];
	$selectsql.="where press like '%{$press}%'";
}
include_once("database.php");
$result=@mysql_query($selectsql) or die("查询信息失败:".mysql_error()."<br/>");
if(mysql_num_rows($result)>0){
	while($row=mysql_fetch_array($result,MYSQL_ASSOC)){
		echo "<tr>";
		foreach($row as $value){
			echo "<td>{$value}</td>";
		}

		echo "<td><a href=\"xiangqing?ISBN={$row['ISBN']}\" target=\"iframe_main\">查看详情</a></td>";
		echo "<td><a href=\"updatebook?ISBN={$row['ISBN']}\" target=\"iframe_main\">修改</a></td>";
		echo "<td><a href=\"deletebook?ISBN={$row['ISBN']}\" target=\"iframe_main\">删除</a></td>";
		echo "</tr>";
	}
}else{
	echo "<script>alert('没有查找到指定的信息!');</script>";
}
?>
</table>
</body>
</html>